package com.canoe.text.common;

import com.canoe.common.CanoeException;
import org.apache.commons.lang3.StringUtils;

/**
 * 针对于text文件进行操作处理的命令参数
 *
 * @author: btm
 * @time: 21:33 2020/9/21
 **/
public enum TextOrder {

    /**
     * 提取
     */
    EXTRACT("-extract","提取"),
    ;

    private String orderName;
    private String desc;

    TextOrder(String orderName, String desc) {
        this.orderName = orderName;
        this.desc = desc;
    }

    /**
     * 通过命令的名字，找到对应的命令
     * @param orderName 二级指令名称
     * @return
     */
    public static TextOrder findByOrderName(String orderName) {
        if (StringUtils.isNotBlank(orderName)) {
            for (TextOrder textOrder : TextOrder.values()) {
                if (orderName.equals(textOrder.getOrderName())) {
                    return textOrder;
                }
            }
        }
        throw new CanoeException("unsupported text order parameter: " + orderName);
    }

    public String getOrderName() {
        return this.orderName;
    }
}
